package org.lanettiesso.dubbo.simple.beans.factory.annotation;

import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;

import java.util.Set;

public class SimpleDubboClassPathBeanDefinitionScanner extends ClassPathBeanDefinitionScanner {

    private Set<BeanDefinitionHolder> beanDefinitionHolders;

    public SimpleDubboClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry) {
        super(registry);
    }

    @Override
    public int scan(String... basePackages) {
        beanDefinitionHolders = super.doScan(basePackages);
        return beanDefinitionHolders.size();
    }

    public Set<BeanDefinitionHolder> getBeanDefinitionHolders() {
        return beanDefinitionHolders;
    }
}
